package com.ouli;

import com.ouli.dao.StudentDao;
import com.ouli.domain.Student;
import com.ouli.service.StudentService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MyText {

    @Test
    public void test01(){
        String config = "applicationContext.xml";
        ApplicationContext ctx = new ClassPathXmlApplicationContext(config);
            String name[] = ctx.getBeanDefinitionNames();
            for(String na:name){
                System.out.println("容器中的对象名称："+na+"|"+ctx.getBean(na));
            }
        }

    @Test
    public void textDaoInsert(){
        String config = "applicationContext.xml";
        ApplicationContext ctx = new ClassPathXmlApplicationContext(config);
        StudentService service = (StudentService) ctx.getBean("studentService");
        Student student = new Student();
        student.setAge(23);
        student.setEmail("zhoufan@qq.com");
        student.setId(4);
        student.setName("周凡");
        int num = service.addStudent(student);
        System.out.println("num===>  git@gitee.com:YuKai-Wu/frame-learning.git"+num);
    }
    }

